<?php

namespace app\admin\controller;

use think\App;
use think\Request;
use think\facade\Session;
use app\admin\services\NoticeService;

class Notice extends Authent
{
    public function __construct(Request $request = null, App $app = null)
    {
        parent::__construct($request, $app);
        $this->NoticeService = new NoticeService();
        global $authstate;
        if(isset($authstate['status']) && $authstate['status'] !=0 ){
            echo json_encode($authstate); die;
        }
    }



    /**
     * @return mixed
     * 首页
     */
    public function index()
    {
        
        return $this->fetch();
    }


    /**
     * @param 获取公告列表
     */
    public function seleclit(){
        $data = $this->NoticeService->datalist();
        return json($data);
    }


    /**
     * @param 添加公告页面
     */
    public function addproble(){

        return $this->fetch();
    }


    /**
     * @param 添加公告
     */
    public function add(){
        $data = $this->NoticeService->addlist();
        return json($data);
    }


    /**
     * @param 修改页面
     */
    public function edit(){
        $data = $this->NoticeService->editdata();
        $this->assign("data",$data);
        return $this->fetch();
    }


    /**
     * @param 修改公告
     */
    public function editit(){
         $data = $this->NoticeService->editlont();
        return json($data);
    }


    /**
     * @param 公告禁用、启用
     */
    public function jinyong(){
        $data = $this->NoticeService->stustlod();
        return json($data);
    }


    /**
     * @param 删除公共
     */
    public function del(){
        $data = $this->NoticeService->delete();
        return json($data);
    }

    /**
     * @param 推送公告
     */
    public function tlaisrol(){
        $data = $this->NoticeService->tlaisrol();
        return json($data);
    }
}